home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT45.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.0 KB  |  60 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 45                         
  5.                                           
  6.  This program loads in some sprites created with the WGT Sprite Editor and
  7.  saves them in a new file using wsavesprites.
  8.                                           
  9.  *** PROJECT ***                                                             
  10.  This program requires the file WGT5_WC.LIB to be linked.                    
  11.                                           
  12.  *** DATA FILES ***                                                          
  13.  Make sure that SPACE.SPR is in your executable directory.                   
  14.                                WATCOM C++ VERSION 
  15. ==============================================================================
  16. */
  17.  
  18. #include <wgt5.h>
  19.  
  20.  
  21. void main(void)
  22. {
  23.   block sprites[10];      /* An array of blocks to load the sprites into.
  24.                  Version 5.0 allows for any number to be
  25.                  loaded in, as long as you pass the same size
  26.                  of the array to the wloadsprites and wfreesprites
  27.                  commands. */
  28.   short oldmode, i;
  29.   color palette[256];
  30.  
  31.   if ( !vgadetected () )
  32.   {
  33.     printf ("Error - VGA card required for any WGT program.\n");
  34.     exit (0);
  35.   }
  36.   printf ("WGT Example #45\n\n");
  37.   printf ("10 sprites are loaded from a file, and then 5 of them are written out to\n");
  38.   printf ("a new file using WSAVESPRITES. Press a key to end the program.\n");
  39.   printf ("\n\nPress any key to continue.\n");
  40.   getch ();
  41.  
  42.   oldmode = wgetmode ();
  43.   vga256 ();
  44.   
  45.   wloadsprites (palette, "space.spr", sprites, 0, 9);
  46.   /* loads the first 10 sprites */
  47.   wsetpalette (0, 255, palette);
  48.   
  49.   for (i = 0; i < 10; i++)                      /* Display them */
  50.     wputblock (i * 30, 0, sprites[i], NORMAL);
  51.  
  52.   /* Now save sprites 0 through 4 in a different file */
  53.   wsavesprites (palette, "saved.spr", sprites, 0, 4);
  54.  
  55.   wtextcolor (1);
  56.   wgtprintf (0, 50, NULL, "Sprites saved.");
  57.   getch ();
  58.   wsetmode (oldmode);
  59. }
  60.